<template>
	<living v-if="!pc"/>
	<livingPc v-else />
</template>

<script>
	export default {
		data() {
			return {
				pc: false,
			};
		},
		components: {
			living: () => import("./living"),
			livingPc: () => import("./livingPc"),
		},
		methods: {
			yzopenid() {
				var openId = ""
				if (sessionStorage.getItem("openid")) {
					openId = sessionStorage.getItem("openid");
				} else {
					openId = localStorage.getItem("youkeId")
				}
				let roomId = this.$route.params.id;
				this.$http.get(this.$api.dealOpenId(openId, roomId)).then(res => {
					this.$store.commit("showVerify",res.data.verify)
					this.$store.state.verifyStatus = res.data.first;
					// setTimeout(() => {
					// 	if (this.info.viewPermission == 0) {
					// 		this.$refs.video.getUserCollect(1)
					// 		this.$store.state.viewPermission = false; //观看限制验证
					// 		this.$refs.video.testStatus(this.$store.state.live);
					// 		if (this.info.menuSwitch == 1) {
					// 			if (this.$store.state.live.menuList.length > 0) {
					// 				this.$refs.menus.menuinfo(this.$store.state.live.menuList[0].id)
					// 			}
					// 		}
					// 	} else {
					// 		if (res.data.verify) { /*如果已经验证过*/
					// 			this.$refs.video.getUserCollect(1)
					// 			this.$store.state.viewPermission = false;
					// 			this.$refs.video.testStatus(this.$store.state.live);
					// 			if (this.info.menuSwitch == 1) {
					// 				if (this.$store.state.live.menuList.length > 0) {
					// 					this.$refs.menus.menuinfo(this.$store.state.live.menuList[0].id)
					// 				}
					// 			}
					// 		} else {
					// 			this.$store.state.viewPermission = true;
					// 			this.$store.state.liveImgShow = false;
					// 		}
					// 	}
					// }, 1000)
				});
				
			},
			// 初始化h5接口
			init() {
				let id = this.$route.params.id;
				this.$http.get(this.$api.getLiveInfo(id)).then(res => {
					if (res.data.code == 0) {
						sessionStorage.setItem("companyId", res.data.liveRoom.companyId);
						sessionStorage.setItem("id", res.data.liveRoom.id);
						document.title = res.data.liveRoom.title; //网址标题
						this.$store.commit("showliveInfo",res.data.liveRoom)
						this.$store.commit("showlive",res.data)
						var ua = window.navigator.userAgent.toLowerCase();
						// if (ua.match(/MicroMessenger/i) == 'micromessenger') {
							this.$share.getWxConfig(res.data.liveRoom);
						// }
						
						// if (this.info.noticeSwitch == 1) {
						// 	this.tabHeight = "calc(100% - 306px)"
						// } else {
						// 	this.tabHeight = "calc(100% - 270px)"
						// }
						// if (this.info.guideSwitch == 1) {
						// 	this.$store.state.bootPageShow = true; //引导图
						// 	this.$router.push("/bootPage/"+id)
						// }
						
					} else if (res.data.code == 500) {
						this.$store.state.emptyPage = true;
					}
				});
			},
			isPc() {
				var isPc = /macintosh|window/.test(navigator.userAgent.toLowerCase());
				if (isPc) {
					this.pc = true
				} else {
					this.pc = false
				}
			},
		},
		created() {
			this.isPc()
			this.$share.isWeiXin(); //判断微信生成游客信息
			this.yzopenid()
			this.init();
		}
	}
</script>

<style lang="less" rel=stylesheet/less> </style>
